Skip to content

Reject cross-origin requests in processCreate and processGet#125

Open
ScottHelme wants to merge 1 commit into
lbuchs:masterfrom
ScottHelme:reject-cross-origin
Open

Reject cross-origin requests in processCreate and processGet#125
ScottHelme wants to merge 1 commit into
lbuchs:masterfrom
ScottHelme:reject-cross-origin

Conversation

@ScottHelme
Copy link
Copy Markdown

Per the proposed Level 3 spec (§7.1 Step 10 for registration, §7.2 Step 13 for authentication), if clientDataJSON.crossOrigin is true, the ceremony should be rejected.

Currently the library does not check this field at all, which means a cross-origin iframe embedding a legitimate site's WebAuthn ceremony would succeed.

This adds a check in both processCreate() and processGet(), after the existing origin validation:

if (\property_exists($clientData, 'crossOrigin') && $clientData->crossOrigin === true) {
    throw new WebAuthnException('cross-origin request not allowed', WebAuthnException::INVALID_ORIGIN);
}

The check is backwards-compatible — crossOrigin is optional in the spec, so existing clients that don't send it are unaffected. Only explicitly cross-origin requests are rejected.

Fixes #124

Per the proposed Level 3 spec (§7.1 Step 10, §7.2 Step 13), reject
ceremonies where clientDataJSON.crossOrigin is true. This prevents
an attacker from embedding a legitimate site's WebAuthn ceremony in
a cross-origin iframe on a malicious domain.

The check is backwards-compatible: crossOrigin is optional in the
spec, so clients that don't send it are unaffected.

Fixes lbuchs#124
@ScottHelme
Copy link
Copy Markdown
Author

Just a heads-up for anyone landing here: we've published a security-focused fork of this library as report-uri/passkeys-php

It already includes this fix, along with several other hardening changes. Huge thanks to @lbuchs for the original work!

This PR is still very much open for upstream consideration, but the fork is available in the meantime for anyone who needs the change today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crossOrigin field in clientDataJSON not validated

1 participant